---
title: Build an application exception detail
summary: Construct a diagnostic ApplicationExceptionDetail record for a caught exception.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-17
library: PdfAPI.SyncFusionCore
reference_type: package
operation_id: OP-SFC-014
trigger: Called by the merge operation and four PdfAPI\Services\ call sites
---

# Build an application exception detail

Builds a `SAIF.Core.Contracts.ApplicationExceptionDetail` diagnostic record carrying environment, machine, user, and formatted exception context for a caught exception, to be logged by the caller.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-SFC-014 |
| **Trigger** | Called by [Merge document ranges into one PDF](merge-document-ranges-into-one-pdf.md) step 5 and four call sites in `PdfAPI\Services\` |
| **Inputs** | `IEnvironmentService`, caller page label (`string`), message (`string`), `Exception` |
| **Outputs** | `ApplicationExceptionDetail` |
| **Primary components** | `PdfHelper.GetApplicationDetail` |
| **Entry point** | `PdfApi.SyncFusionCore\PdfHelper.cs` |

## Steps

1. Construct `SAIF.Core.Contracts.ApplicationExceptionDetail` with `Application = "PdfApi"`
   (hard-coded) ([BR-SFC-037](../business-rules.md#br-sfc-037-exception-detail-attributed-to-pdfapi)).
2. Set `Environment` from `envSvc.GetApplicationTrack()` — `IEnvironmentService` is a
   caller-injected dependency from `SAIF.Framework.Core` — `Machine` from `Environment.MachineName`, `User` from `Environment.UserName`, and `ExceptionDate` from `DateTime.Now` ([BR-SFC-038](../business-rules.md#br-sfc-038-exception-detail-captures-diagnostic-context)).
3. Set `Page` to the supplied caller label, `Message` to the supplied message, and `State` to
   `ex.GetFullFormattedException()` (`SAIF.Common.Extensions`).

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start(["GetApplicationDetail called<br>with envSvc, page, message, ex"]) --> Construct["Construct<br>ApplicationExceptionDetail,<br>Application = PdfApi"]
	Construct --> Context["Set Environment, Machine,<br>User, ExceptionDate"]
	Context --> State["Set Page, Message,<br>State = formatted exception"]
	State --> Return([Return ApplicationExceptionDetail])
```

## Failure and edge-case behavior

- This operation performs no I/O of its own beyond reading environment/process values; it does not
  log or throw. The caller is responsible for passing the constructed detail to `ILogService`.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `PdfApi.SyncFusionCore\PdfHelper.cs`
